package org.hxd.client.order.dao;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Update;
import org.hxd.pojo.Orderitem;
import org.hxd.pojo.Orders;

public interface OrderDao {

    @Insert("insert into orders (id,money,receiverAddress,receiverName,receiverPhone,user_id) " +
            "values(#{id},#{money},#{receiverAddress},#{receiverName},#{receiverPhone},#{user.id})")
    void createOrder(Orders orders);

    @Insert("insert into orderitem (order_id,product_id,buynum) " +
            "values(#{orders.id},#{products.id},#{buynum})")
    void insertOrderitem(Orderitem orderitem);

    @Update("update products set pnum = pnum - #{buynum} where id = #{products.id}")
    void ModifyProductNum(Orderitem orderitem);

    @Update("update orders set paystate = 1 where id = #{order_id}")
    void paySuccess(String order_id);
}
